package com.wly.ui.gamescene
{
	import com.wly.datapool.DataPool;
	import com.wly.interval.IntervalCallBack;
	import com.wly.sound.SoundManager;
	import com.wly.ui.common.BaseSprite;
	import com.wly.ui.common.EffectLayer;
	import com.wly.ui.common.GlobalInfo;
	
	import flash.display.DisplayObject;
	import flash.geom.Point;
	
	import Box2D.Collision.b2AABB;
	
	public class HitItem extends BaseSprite implements IHitObject
	{
		private var _isCanHitted:Boolean;
		private var _parentGrid:HitItemGrid;
		
		public function HitItem()
		{
			super();
			_isCanHitted = true;
		}
		
		public function set parentGrid(grid:HitItemGrid):void
		{
			_parentGrid = grid;
		}
		
		protected function get itemScore():int
		{
			return 0;
		}
		
		protected function get canHit():Boolean
		{
			return _isCanHitted;
		}
		
		protected function get effectSound():String
		{
			return null;
		}
		
		public function onHit(obj:DisplayObject, hitPos:Point):Boolean
		{
			var hitObj:Player = obj as Player;
			if(hitObj)
			{
				if(this.effectSound)
				{
					SoundManager.instance.playEffectSound(effectSound);
				}
				
				if(this.parent)
				{
					DataPool.getInstance().mainPlayer.addScore(itemScore);
					EffectLayer.getIntance().addScoreEffect(itemScore, this.parent.localToGlobal(new Point(this.x, this.y)));
					this.parent.removeChild(this);
					return false;
				}
				

			}
			return true;
		}
		
	}
}